#pragma once
#include <QMap>
#include "ComponentBase.h"
//#include "wcs_data.h"

class HttpSend;
class WCSSend : public ComponentBase
{
	Q_OBJECT
public:
	WCSSend(QObject* parent);
	~WCSSend();

	//任务完成
	bool SendTaskFinishInfo(const QByteArray& data, QString& errmsg);

	bool SendToWCS(const QString& path, const QByteArray& data, QByteArray& ans);
	// 订阅接口，提供给其它组件订阅本组件消息的接口
	virtual bool RegisterSubscriberFunction(int type, Callback callback) override;

protected:
	// 组件初始化处理函数
	virtual int ComponentInit() override;
	/*自检接口*/
	virtual bool ComponentCheckSelfState() override;
	/*复位接口*/
	virtual bool ComponentSelfReset() override;
private:

	int HttpResend(const QString& path, const QByteArray& data, QByteArray& ans, int times);
private:
	QString m_host;
	HttpSend* m_send = nullptr;
	QString m_taskId = "0";

	QMap<WCSendType, QVector<std::function<int(const QByteArray&)>>> m_subscribers;
};
